#ifndef __LOG_H__
#define __LOG_H__

#include <stdio.h>
#include "type.h"

extern U8 gDebug;

#define DUMP(msg, ...)

#define DEBUG(msg, ...) do {\
        if (gDebug)\
            fprintf(stderr, "D:%s[%d] "msg"\n", __func__, __LINE__, ##__VA_ARGS__);\
    } while(0)

#define INFO(msg, ...) do {\
        fprintf(stderr, "I:%s[%d] "msg"\n", __func__, __LINE__, ##__VA_ARGS__);\
    } while(0)

#define WARN(msg, ...) do {\
        fprintf(stderr, "W:%s[%d] "msg"\n", __func__, __LINE__, ##__VA_ARGS__);\
    } while(0)

#define ERROR(msg, ...) do{\
        fprintf(stderr,"E:%s[%d] "msg"\n", __func__, __LINE__, ##__VA_ARGS__);\
        exit(0);\
    }while(0)

#define ENTER() do {\
        if (gDebug)\
            fprintf(stderr, "enter %s[%d]\n", __func__, __LINE__);\
    } while(0)

#define EXIT() do {\
        if (gDebug)\
            fprintf(stderr, "exit %s[%d]\n", __func__, __LINE__);\
    } while(0)

#endif